﻿using MediatR;
using SY.BasicData.Api.Read.Applications.DeepProcessing.Command;
using SY.BasicData.Domain.DeepProcessing;
using SY.BasicData.ErrorCode;
using SY.BasicData.Infrastructures;

namespace SY.BasicData.Api.Read.Applications.DeepProcessing.CommandHandler
{
    public class DeepProcessingCompanyCommandHandler : IRequestHandler<DeepProcessingCompanyCommand, ApiResult<DeepVendorModel>>
    {
        private readonly IBaseRepository<DeepVendorModel> _repository;

        public DeepProcessingCompanyCommandHandler(IBaseRepository<DeepVendorModel> repository)
        {
            _repository = repository;
        }

        public Task<ApiResult<DeepVendorModel>> Handle(DeepProcessingCompanyCommand request, CancellationToken cancellationToken)
        {
            ApiResult<DeepVendorModel> result = new ApiResult<DeepVendorModel>();
            result.Code = ApiEnum.Success;
            result.Message = "深加工企业申请表明细展示成功";
            var list = _repository.GetAll().Where(x => x.Batch == request.Batch).FirstOrDefault();
            result.Data = list;
            return Task.FromResult(result);
       
        }
    }
}
